package com.hnchances.grade.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.hnchances.grade.common.utils.PageUtils;
import com.hnchances.grade.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hnchances.grade.entity.ClassEntity;
import com.hnchances.grade.service.ClassService;



/**
 * 
 *
 * @author lpj
 * @email ${email}
 * @date 2022-08-27 15:10:23
 */
@RestController
@RequestMapping("grade/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    /**
     * 列表
     */
    @PostMapping("/list")
    //@RequiresPermissions("grade:class:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = classService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("grade:class:info")
    public R info(@PathVariable("id") Integer id){
		ClassEntity classEntity = classService.getById(id);

        return R.ok().put("class", classEntity);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("grade:class:save")
    public R save(@RequestBody ClassEntity classEntity){
		classService.save(classEntity);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("grade:class:update")
    public R update(@RequestBody ClassEntity classEntity){
		classService.updateById(classEntity);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    // @RequiresPermissions("grade:class:delete")
    public R delete(@RequestBody Integer[] ids){
		classService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
